﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.Topo
{
    /// <summary>
    /// 
    /// </summary>
    public class SERVICECONNECTION
    {
        private readonly OracleDAL.Topo.SERVICECONNECTION dal = new OracleDAL.Topo.SERVICECONNECTION();
        /// <summary>
        /// 
        /// </summary>

        public SERVICECONNECTION()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string SERVICECONNECTIONID)
        {
            return dal.Exists(SERVICECONNECTIONID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Model.Topo.SERVICECONNECTION model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Model.Topo.SERVICECONNECTION model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string SERVICECONNECTIONID)
        {

            dal.Delete(SERVICECONNECTIONID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Topo.SERVICECONNECTION GetModel(string SERVICECONNECTIONID)
        {

            return dal.GetModel(SERVICECONNECTIONID);
        }

        ///// <summary>
        ///// 得到一个对象实体，从缓存中。
        ///// </summary>
        //public Model.Topo.SERVICECONNECTION GetModelByCache(string SERVICECONNECTIONID)
        //{

        //    string CacheKey = "SERVICECONNECTIONLISTModel-" + SERVICECONNECTIONID;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(SERVICECONNECTIONID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (Model.Topo.SERVICECONNECTION)objModel;
        //}

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Topo.SERVICECONNECTION> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Topo.SERVICECONNECTION> DataTableToList(DataTable dt)
        {
            List<Model.Topo.SERVICECONNECTION> modelList = new List<Model.Topo.SERVICECONNECTION>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Topo.SERVICECONNECTION model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Topo.SERVICECONNECTION();
                    model.SERVICECONNECTIONID = dt.Rows[n]["SERVICECONNECTIONID"].ToString();
                    model.SERVICECONNECTIONNAME = dt.Rows[n]["SERVICECONNECTIONNAME"].ToString();
                    model.SERVICECONNECTIONTYPE = dt.Rows[n]["SERVICECONNECTIONTYPE"].ToString();
                    model.BACKGROUNDIMAGE = dt.Rows[n]["BACKGROUNDIMAGE"].ToString();
                    model.SHORTHAND = dt.Rows[n]["SHORTHAND"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}
